﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    [ObjectEvent]
    public class Features_StableComponentEvent : ObjectEvent<Features_StableComponent>, IAwake
    {
        public void Awake()
        {
            Get().Awake();
        }
    }

    public class Features_StableComponent : BattleEventComponent
    {
        bool IfAdd=false;
        readonly int PowerAdd = 1000;
        public override BattleEventType[] EventType { get; set; } = new BattleEventType[] { BattleEventType.FightStart, BattleEventType.FightEnd };

        public override async Task RunEvent(BattleEventType eventType, FightModel fightModel, params object[] param)
        {
            DamageInfo damageInfo = param[0] as DamageInfo;
            BattleCard battleCard = GetEntity<BattleCard>();
            if (battleCard != damageInfo.DefenceCard)
                return;
            if (eventType == BattleEventType.FightStart)
            {
                damageInfo.DefenceCard.GetComponent<SpellCardComponent>().Power += PowerAdd;
                //card.GetComponent<SpellCardComponent>().Power += PowerAdd;
                Log.Debug($"卡牌{battleCard.CardName}因为稳定特性提升了{PowerAdd}战斗力");
                IfAdd = true;
            }
            if (eventType == BattleEventType.FightEnd && IfAdd)
            {
                damageInfo.DefenceCard.GetComponent<SpellCardComponent>().Power -= PowerAdd;
            }
        }
    }
}
